package com.ctshk.sapp.localfun.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.localfun.dto.LocalFunProductDetail;
import com.ctshk.rpc.localfun.dto.LocalFunReservationGetOrderDTO;
import com.ctshk.rpc.localfun.dto.LocalFunReservationListDTO;
import com.ctshk.rpc.localfun.req.LocalFunReservationListReq;
import com.ctshk.rpc.localfun.req.LocalFunReservationOrderReq;
import com.ctshk.rpc.localfun.service.ILocalFunReservationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description
 * @Author wansi <gaylen15527491065@yeah.net>
 * @Date 2021/3/25
 */
@Api(value="预订中心", tags="当地游玩-预订中心")
@RestController
@RequestMapping("/local-fun-reservation")
public class LocalFunReservationController extends BaseController {

    @DubboReference
    private ILocalFunReservationService iLocalFunReservationService;

    @ApiOperation(value = "预订中心-推荐页预订查询", notes = "预订中心产品列表",tags = "当地游玩-预订中心")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.QUERY, operTitle = "当地游玩预订中心产品列表", operDesc = "查询产品列表")
    @PostMapping(value = "/list")
    public Result<PageResponse<LocalFunReservationListDTO>> queryList(@RequestBody LocalFunReservationListReq reservationListReq){
        PageResponse<LocalFunReservationListDTO> result = iLocalFunReservationService.queryList(reservationListReq,getCurrentUser(getRequest()));
        return Result.success(result);
    }

    @ApiOperation(value = "预订中心景点门票默认推荐页", notes = "预订中心默认推荐页",tags = "当地游玩-预订中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "预订中心默认推荐页", operDesc = "预订中心默认推荐页")
    @GetMapping("/recommended/info")
    public Result<List<LocalFunReservationListDTO>> recommendedList(){
        List<LocalFunReservationListDTO> result = iLocalFunReservationService.recommendedList(getCurrentUser(getRequest()));
        return Result.success(result);
    }

    @ApiOperation(value = "预订中心景点门票默认推荐页", notes = "预订中心默认推荐页",tags = "当地游玩-预订中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "预订中心默认推荐页", operDesc = "预订中心默认推荐页")
    @GetMapping("/recommended/info2")
    public Result<List<LocalFunReservationListDTO>> recommendedList2(){
        List<LocalFunReservationListDTO> result = iLocalFunReservationService.recommendedList2(getCurrentUser(getRequest()));
        return Result.success(result);
    }

    @ApiOperation(value = "预订中心产品详情", notes = "预订中心产品详情页查询")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "预订中心产品详情页查询", operDesc = "预订中心产品详情页查询")
    @GetMapping("/info/{id}")
    public Result<LocalFunProductDetail> getLocalFunProductDetail(@PathVariable Long id){
        LocalFunProductDetail detail = iLocalFunReservationService.getLocalFunProductDetail(id,getCurrentUser(getRequest()));
        return Result.success(detail);
    }

    @ApiOperation(value = "预订中心当地游玩-填写订单页-根据产品id获取订单信息", notes = "预订中心当地游玩-填写订单页-根据产品id获取订单信息")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "预订中心当地游玩-填写订单页-根据产品id获取订单信息", operDesc = "预订中心当地游玩-填写订单页-根据产品id获取订单信息")
    @PostMapping("/get-order")
    public Result<LocalFunReservationGetOrderDTO>getOrderInfo(@RequestBody LocalFunReservationOrderReq LocalFunReservationOrderReq){
        LocalFunReservationGetOrderDTO result = iLocalFunReservationService.getOrderInfo(LocalFunReservationOrderReq);
        return Result.success(result);
    }
}
